import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import reportWebVitals from "./reportWebVitals";
import store from "./store"; // 引入创建好的store实例
import { ErrorBoundary } from "react-error-boundary";
import Router from "router";

// 引入样式
import "antd/dist/antd.css";
import "./assets/style/index.less";

ReactDOM.render(
  <Provider store={store}>
    {/* 捕获错误边界 */}
    <ErrorBoundary
      fallbackRender={({ error, resetErrorBoundary }) => (
        <div role="alert">
          <div>错误信息</div>
          <pre>{error.message}</pre>
          <button onClick={resetErrorBoundary}>重试</button>
        </div>
      )}
    >
      <Router />
    </ErrorBoundary>
  </Provider>,
  document.getElementById("root")
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
